﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LED_Tester
{
    public partial class frmBSDFwavelength : Form
    {
        public double Wavelength1;
        public double Wavelength2;

        public double Trans;//滤光片透过率---------------------2016-08-25

        public frmBSDFwavelength()
        {
            InitializeComponent();
        }

        private void BSDFwavelength_Load(object sender, EventArgs e)
        {

            //添加BSDF测量的滤光片选项--------------------------2016-08-25
            txbTrans.Enabled = false;
            txbTrans.Text = "1.0";


        }

        private void button1_Click(object sender, EventArgs e)
        {
            double tmp;

            if ( !double.TryParse(textBox1.Text, out tmp)   //判断是否为数字
                || !double.TryParse(textBox2.Text, out tmp) 
                || !double.TryParse(txbTrans.Text, out tmp)
                ||double.Parse(textBox1.Text) < 380 || double.Parse(textBox1.Text) > 830 
                || double.Parse(textBox1.Text) < 380 || double.Parse(textBox2.Text) > 830 
                || double.Parse(textBox1.Text) > double.Parse(textBox2.Text)
                || double.Parse(txbTrans.Text)<0 || double.Parse(txbTrans.Text)>1) //透过率数值有效性判断
                {
                    MessageBox.Show("请输入正确数值！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                try
                {
                    Wavelength1 = double.Parse(textBox1.Text);
                    Wavelength2 = double.Parse(textBox2.Text);
                    Trans = double.Parse(txbTrans.Text);
                    //this.Close();
                }
                catch(Exception)
                {
                    MessageBox.Show("请输入正确数值！", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                this.Close();
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            txbTrans.Enabled = true;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            txbTrans.Enabled = false;
            txbTrans.Text = "1.0";
        }
    }
}
